import { Injectable } from '@angular/core';

import { HttpClient } from '@angular/common/http';

import { APIBase } from 'app/modules/base/api-base';

@Injectable({
  providedIn: 'root',
})
export class RepositoryService extends APIBase<any, Repository> {
  constructor(protected http: HttpClient) {
    super(http, '/api/admin/repository');
  }

  put(repo: Repository) {
    this.http.put('/api/admin/repository/' + repo.id, repo).toPromise();
  }
  sync() {
    return this.http.post('/api/admin/repository/sync', null).toPromise();
  }
}

export interface Repository {
  id: number;
  enable_source: boolean;
  uri: string;
  distribution: string;
  component_list: string[];
}
